<?php
/**
 * @Author: Marte
 * @Date:   2017-08-22 08:24:44
 * @Last Modified by:   Marte
 * @Last Modified time: 2017-08-22 09:01:05
 */
session_start();
if(!isset($_SESSION['username']))
{
    echo "<script>alert('请先登录！');window.history.back();</script>";
    exit ;
}
require '../data/config_connect.php';
$_sql='select recom from books where bookid="'.$_GET['id'].'"';
$_result=$_mysql->query($_sql);
$_assoc=$_result->fetch_assoc();
$num=$_assoc['recom'];
$num=$num+1;
$sqll='update books set recom="'.$num.'" where bookid="'.$_GET['id'].'" ';
if($_mysql->query($sqll))
{
    $_user=$_SESSION['username'];
    $id=$_GET['id'];
    $sql3 = 'INSERT INTO recom (username, bookid,time)
    VALUES ("'.$_user.'", "'.$id.'",now())';
    if($_mysql->query($sql3))
    {
         echo "<script>alert('月票投送成功！');window.history.back();</script>";
    }
    else
    {
        echo "<script>alert('月票投送失败！');window.history.back();</script>";
    }



}
else{
    echo "<script>alert('月票投送失败！');window.history.back();</script>";
}
?>
